package onlineCodingQuizSubmission

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method("POST")
        url("/api/v3/onlineCodingSubmission")
        headers {
            contentType(applicationJsonUtf8())
        }
        body("""
        {
            "userAnswerCode":"userAnswerCode",
            "language":"java",
            "name":"name",
            "assignmentId":1,
            "studentId":1
        }
        """)
        bodyMatchers {
            jsonPath('$.userAnswerCode', byRegex("[\\s\\S]+"))
            jsonPath('$.language', byRegex("[\\s\\S]+"))
            jsonPath('$.name', byRegex("[\\s\\S]+"))
            jsonPath('$.assignmentId', byRegex(number()))
            jsonPath('$.studentId', byRegex(number()))
        }
    }
    response {
        // amazon
        status(201)
        body("""
        {
            "id":1,
            "assignmentId":1,
            "quizId":1,
            "userId":1,
            "userAnswer":"userAnswer",
            "status":null,
            "result":null,
            "answerLanguage":"answerLanguage",
            "buildNumber":null
        }
        """)
        bodyMatchers {
            jsonPath('$.id', byRegex(number()))
            jsonPath('$.assignmentId', byRegex(number()))
            jsonPath('$.quizId', byRegex(number()))
            jsonPath('$.userId', byRegex(number()))
            jsonPath('$.userAnswer', byRegex("[\\s\\S]+"))
            jsonPath('$.answerLanguage', byRegex("[\\s\\S]+"))
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }
}
